<?php
    $phonenum = $_POST['phonenum'];
    $password = $_POST['password'];

    $con = mysqli_connect('localhost','root','123456','hua');
    $selectSql = "SELECT * FROM `userinfo` WHERE `phonenum`='$phonenum' AND `password`='$password'";

    $selectRes = mysqli_query($con,$selectSql);

    $row = mysqli_fetch_assoc($selectRes);

    if($row){ 
        die('用户名已经存在 请重新输入');
    }

    $insertSql = "INSERT INTO `userinfo` VALUES(null,'$phonenum','$password')";
    $insertRes = mysqli_query($con,$insertSql);

    if(!$insertRes){
        die('添加失败');
    }
    $arr = array('code'=>$insertRes,'msg'=>'添加成功');
    print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));
?>